package org.example.proxy.cglib;

import net.sf.cglib.core.DebuggingClassWriter;
import net.sf.cglib.proxy.Callback;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.NoOp;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) {


        System.setProperty(DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "E:\\Project\\proxy");
        Enhancer enhancer = new Enhancer();
        enhancer.setCallbacks(new Callback[]{new DynamicMethodInterceptor(),new DynamicTwoMethodInterceptor(), NoOp.INSTANCE,new FixedValueInterceptor(),new DispatcherCallback(),new LazyLoadCallback(),new InvocationCallback(new InvokeObject())});
        enhancer.setCallbackFilter(new MethodFilter());
        enhancer.setSuperclass(HelloService.class);
        enhancer.setUseFactory(true);
        enhancer.setUseCache(false);
        HelloService helloService = (HelloService) enhancer.create();
//        helloService.age();
//        helloService.noProxy();
        helloService.name("111111");



        /*静态方法创建*/
//       HelloService helloService1  = (HelloService) Enhancer.create(HelloService.class,new Class[]{PersonService.class}, new DynamicTwoMethodInterceptor());
//        String name1 = helloService1.name("444444444");
//        System.out.println(name1);
    }
}
